<!-- 我的查询 -->

<template>
  <WebSearch>
    <template #btn>
      <BtnAdd />
      <BtnPrimary title="重新建模" @click="toSubmit" />
      <BtnPrimary title="全部重新建模" @click="toSubmitAll" />
    </template>

    <ParamInput label="姓名" bind="name" />
    <ParamInput label="证件号" bind="certificateNumber" />
    <ParamSelect label="性别" bind="sex" :dict="CORE.DICT.GENDER" narrow />
  </WebSearch>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MySearch',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb()],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 重新建模
     */
    toSubmit() {
      const { idList, faceLibId } = this.param

      if (!idList.length) {
        CORE.MSG.warning('请选择人员')
        return
      }

      Object.assign(this.one, { faceLibId, facePersonIdList: idList })
      this.startSubmit()
    },

    /**
     * 全部重新建模
     */
    async toSubmitAll() {
      const { faceLibId } = this.param

      await CORE.CONFIRM.warning('确定全部重新建模吗？', '全部重新建模')

      Object.assign(this.one, { faceLibId, facePersonIdList: [] })
      this.startSubmit()
    },
  },
}
</script>
